home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
tex
/
devnag.zip
/
DEVNAG.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-05-09
|
41KB
|
1,229 lines
/* devnag.c
Preprocessor for TeX for texts containing Devanagari characters.
Copyright (C) 1991 University of Groningen, The Netherlands
Author: Frans J. Velthuis
Internet: velthuis@rc.rug.nl
Bitnet: velthuis@hgrrug5
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <ctype.h>
#define TRUE 1
#define FALSE 0
#define ill_char 29
#define dummy 30
#define end_of_file 30
#define end_of_line 31
#define n_noligs 40
/* ch_class values */
#define illegal 0
#define cmr 1
#define control 2
#define dn 3
#define numeral 4
/* ch_subclass values */
#define lo_vowel 0
#define hi_vowel 1
#define consonant 2
#define special 3
#define LBRACE 273
#define RBRACE 264
#define RE 263
#define RDT 266
#define RN 265
#define RS 256
#define VIRAAM 94
short ch_class;
short ch_subclass ;
short join_type;
struct char_def {
short ch_typ, ch_subtyp, ch_code, ch_subcode;
};
struct cons_joins {
short n_ligs, lig_code;
short r_type, j_code;
};
struct ligs {
char sym_code;
short sym_new, join_ptr;
unsigned char in_use;
};
struct char_def *c_ptr;
struct cons_joins *q_ptr;
char tmp[4];
char string[10];
char wrong[10];
char cstr[2];
FILE *f_in,*f_out,*fopen();
char *p_in,*p_out,*s_ptr,*o_ptr;
char **p_match;
char *strchr();
short i, j, buf_length;
int number;
char symbol;
char com_str[80], prompt[80];
char infil[80], outfil[80];
char inbuf[133], outbuf[133], tmpbuf[133];
char word[500];
char *p;
short syll[30];
int n_halves;
short half_codes[30];
short joincode;
unsigned char dn_yes, hindi_mode, dollar_mode, d_found;
unsigned char no_dn, result, buf_ptr, wait_syl, lin_obey;
unsigned char error, cons_seen, vow_seen, front_r, cmr_mode, num_mode;
short cons_ptr, chr_ptr, cons_code;
short nolig[n_noligs] = {2,3,6,7,16,25,27,34,35,39,40,46,47,49,
56,58,59,62,65,78,81,82,84,85,86,87,88,89,90,91,92,93,94,95,
96,98,99,100,101,105};
short ligptrs[105] = {0,1,2,3,4,6,7,9,11,12,13,14,118,16,17,18,
19,20,21,22,23,24,25,26,27,28,29,
30,31,32,33,34,35,36,38,39,40,41,
42,43,44,45,46,47,48,49,50,52,53,119,54,
55,56,58,59,60,61,62,63,64,65,66,
68,69,70,71,72,73,74,75,76,77,78,80,
81,82,84,85,86,87,88,89,90,91,92,93,
94,95,96,98,99,100,101,102,104,117,105,
106,107,108,109,110,111,112,113};
struct char_def table[127] = {
{illegal,special,0,0}, /* 1 not used */
{dn,consonant,'\126',34}, /* 2 .t */
{dn,consonant,'\130',36}, /* 3 .d */
{dn,special,'\72',0}, /* 4 .o */
{dn,consonant,'\132',1}, /* 5 .n */
{dn,consonant,'\161',2}, /* 6 .s */
{dn,lo_vowel,'\33',2}, /* 7 .r */
{dn,consonant,'\13',3}, /* 8 .g */
{dn,special,'\54',0}, /* 9 .h */
{dn,special,'\137',0}, /* 10 .a */
{dn,special,'\24',0}, /* 11 .. */
{dn,consonant,'\14',4}, /* 12 .K */
{dn,consonant,'\127',35}, /* 13 .T */
{dn,consonant,'\131',57}, /* 14 .D */
{dn,lo_vowel,'\30','\37'}, /* 15 .l */
{dn,lo_vowel,'\31','\174'}, /* 16 .L */
{dn,lo_vowel,'\21','\16'}, /* 17 .R */
{dn,consonant,'\122',32}, /* 18 "n */
{dn,consonant,'\146',5}, /* 19 "s */
{dn,consonant,'\170',0}, /* 20 Rh */
{dn,consonant,'\32',11}, /* 21 ~n */
{dn,hi_vowel,267,262}, /* 22 ~o */
{dn,hi_vowel,259,4}, /* 23 ~a */
{dn,consonant,'\35',31}, /* 24 ~r */
{illegal,special,0,0}, /* 25 not used */
{illegal,special,0,0}, /* 26 not used */
{illegal,special,0,0}, /* 27 not used */
{illegal,special,0,0}, /* 28 not used */
{illegal,special,0,0}, /* 29 not used */
{control,special,0,0}, /* 30 dummy */
{control,special,0,0}, /* 31 end_of_line */
{control,special,0,0}, /* 32 space */
{cmr,special,0,0}, /* ! */
{illegal,special,0,0}, /* " */
{dn,special,'\25',0}, /* # */
{illegal,special,0,0}, /* $ */
{illegal,special,0,0}, /* % */
{dn,special,0,0}, /* & */
{cmr,special,0,0}, /* ' to - */
{cmr,special,0,0}, /* ' to - */
{cmr,special,0,0}, /* ' to - */
{cmr,special,0,0}, /* ' to - */
{cmr,special,0,0}, /* ' to - */
{cmr,special,0,0}, /* ' to - */
{cmr,special,0,0}, /* ' to - */
{illegal,special,0,0}, /* . */
{dn,special,'\40',0}, /* / */
{numeral,special,0,0}, /* 0 to 9 */
{numeral,special,0,0}, /* 0 to 9 */
{numeral,special,0,0}, /* 0 to 9 */
{numeral,special,0,0}, /* 0 to 9 */
{numeral,special,0,0}, /* 0 to 9 */
{numeral,special,0,0}, /* 0 to 9 */
{numeral,special,0,0}, /* 0 to 9 */
{numeral,special,0,0}, /* 0 to 9 */
{numeral,special,0,0}, /* 0 to 9 */
{numeral,special,0,0}, /* 0 to 9 */
{cmr,special,0,0}, /* : and ; */
{cmr,special,0,0}, /* : and ; */
{illegal,special,0,0}, /* < */
{cmr,special,0,0}, /* = */
{illegal,special,0,0}, /* > */
{cmr,special,0,0}, /* ? */
{dn,special,'\177',0}, /* @ */
{dn,hi_vowel,258,'\101'}, /* A */
{dn,consonant,'\102',6}, /* B */
{dn,consonant,'\103',33}, /* C */
{dn,consonant,'\104',7}, /* D */
{dn,hi_vowel,259,'\173'}, /* E */
{illegal,special,0,0}, /* F */
{dn,consonant,'\107',8}, /* G */
{dn,special,'\54',0}, /* H */
{dn,hi_vowel,'\111','\106'}, /* I */
{dn,consonant,'\112',9}, /* J */
{dn,consonant,'\113',10}, /* K */
{dn,consonant,'\17',30}, /* L */
{dn,special,'\134',0}, /* M */
{illegal,special,0,0}, /* N */
{dn,hi_vowel,260,'\117'}, /* O */
{dn,consonant,'\120',12}, /* P */
{illegal,special,0,0}, /* Q */
{dn,consonant,'\167',0},